package com.gmall.search.service;

import com.gmall.common.result.Result;
import com.gmall.model.search.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.stereotype.Service;

@Service
public class IndexService {

    @Autowired
    private ElasticsearchRestTemplate elasticsearchRestTemplate;

    public Result createIndex() {
        //创建索引
        elasticsearchRestTemplate.createIndex(Goods.class);
        //设置mapping
        elasticsearchRestTemplate.putMapping(Goods.class);
        return Result.ok();
    }
}
